package com.zzpct.wh.work.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.zzpct.wh.work.myapplication.entity.QichePingpai;
import com.zzpct.wh.work.myapplication.service.QcppService;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getQichePingpaiInfo();
    }

    private void getQichePingpaiInfo() {
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("http://apis.juhe.cn/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        QcppService qcpPservice = retrofit.create(QcppService.class);

        Map<String,String> map=new HashMap<>();
        map.put("key","79729168b7661c89f1f4e56936121f31");
        map.put("first_letter","E");
        Call<QichePingpai>allPinpai=qcpPservice.getAllPinpai(map);
        allPinpai.enqueue(new Callback<QichePingpai>() {
            @Override
            public void onResponse(Call<QichePingpai> call, Response<QichePingpai> response) {
                QichePingpai qichePingpai = response.body();
                Log.d(TAG, "onResponse: "+qichePingpai.getResult().size());
            }

            @Override
            public void onFailure(Call<QichePingpai> call, Throwable t) {
                Log.d(TAG, "onFailure: "+t.getMessage());
            }
        });



       /* Call<QichePingpai> allPinpai=qcpPservice.getAllPinpai("79729168b7661c89f1f4e56936121f31","C");
        allPinpai.enqueue(new Callback<QichePingpai>() {
            @Override
            public void onResponse(Call<QichePingpai> call, Response<QichePingpai> response) {
                QichePingpai qichePingpai = response.body();
                Log.d(TAG, "onResponse: "+qichePingpai.getResult().size());
            }

            @Override
            public void onFailure(Call<QichePingpai> call, Throwable t) {
                Log.d(TAG, "onFailure: "+t.getMessage());

            }
        });*/
    }
}
